--
-- Database version table
--
CREATE TABLE DatabaseVersion (
	CurrentVersion INT
)
GO

INSERT INTO DatabaseVersion(CurrentVersion) VALUES(1)
GO

--
-- Account
--
CREATE TABLE [Account](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL
)
GO

ALTER TABLE [Account]
ADD CONSTRAINT PK_Account PRIMARY KEY CLUSTERED ([Id] ASC)
WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO


--
-- Category
--
CREATE TABLE [Category](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[Mask] [nvarchar](max) NULL
)
GO

ALTER TABLE [Category]
ADD CONSTRAINT PK_Category PRIMARY KEY CLUSTERED ([Id] ASC)
WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO


--
-- Charge
--
CREATE TABLE [Charge](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Time] [datetime] NOT NULL,
	[Name] [nvarchar](max) NOT NULL,
	[Amount] [money] NOT NULL,
	[AccountId] [int] NULL,
	[CategoryId] [int] NULL
)
GO

ALTER TABLE [Charge]
ADD CONSTRAINT PK_Charge PRIMARY KEY CLUSTERED ([Id] ASC)
WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
